package cn.gwm.flink.streaming.strategy.vehiclepredict;

import cn.gwm.flink.streaming.constant.ChargePredictFields;
import com.alibaba.fastjson.JSONObject;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.util.Collector;

import java.io.Serializable;

/**
 * @author : GW00280745
 * @date : 2023/4/26 13:05
 * @description :
 * 实时更新每1%soc的时间到phoenix中
 *
 */
public class OneSoc implements Serializable {
    /**
     *
     * @param srcDataStream
     */
    public void process(DataStream<JSONObject> srcDataStream){
        //实时更新
        srcDataStream
                .keyBy((KeySelector<JSONObject, Object>) value -> value.getString(ChargePredictFields.ins().srcFieldVin))
                .process(new OneSocKeyFunction())
                .addSink(new OneSocSink())
        ;
    }
}
